package Leetcode100;

import java.util.HashMap;

public class Leetcode1 {
    public int[] twoSum(int[] nums, int target) {
        HashMap<Integer,Integer> hashMap=new HashMap();
        for (int i = 0; i < nums.length; i++) {
            if(hashMap.containsKey(nums[i])){
                return new int[]{i,hashMap.get(nums[i])};
            }
            hashMap.put(target-nums[i],i);
        }
        return new int[0];
    }
}
